home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: overloading and ellipsis
- Date: 3 Apr 1996 02:30:44 GMT
- Organization: Borland International
- Message-ID: <4jsnsk$mrh@druid.borland.com>
- References: <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>,
- thuerman@informatik.uni-bremen.de says...
- >
- >I'd like to overload a function with ellipsis but g++ doesn't let me
- >do that. Should that be possible?
- >
- >void send(char *fmt, ...)
- >{
- > ;
- >}
- >
- >void send(char *fmt, va_list)
- >{
- > ;
- >}
- >
- >void send(char *s)
- >{
- > ;
- >}
- >
- >main()
- >{
- > va_list ap;
- >
- > send("abc %d\n", 13); // ok, calls first function
- >
- > send("abc %d\n", ap); // ok, calls second function
- >
- > send("abc\n"); // error: ambiguous
- >}
- >
- >The second call is ok, because the argument ap does match better to
- >va_list than to "...", according to ARM r.13.2
- >
- > [5] Match with ellipsis: Sequences that involve matches with
- > ellipsis are worse than all others.
- >
- >This, of course sequences of conversion, so it doesn't apply to the
- >third call in my example where no conversion is neccessary.
- >But nevertheless I would think that the third function matches better
- >than the first for the third call in main(), so there would be exactly
- >one best match and the call legal.
- >Does the ARM say something about this, and is g++ correct?
-
- The third function does not match better. There is one parameter, and both the
- second and third versions of the function provide an exact match on that
- parameter. There are no other parameters, so no other matches are considered.
- The set of functions that match on the first parameter has more than one
- member, so the call is ambiguous.
-
-